<?php
class Comment_WidgetController extends Clu_Controller_Action_Widget
{
	
	public function init()
	{
		//require_once (APP_PATH.'/modules/comment/Model/Comment.php');	
		//require_once (APP_PATH.'/modules/comment/Form/Comment.php');
		$this->m = new comment_Model_Service();
		parent::init();
	}
	

	public function viewCommentListAction()
	{
		$data = array();
		$data['content_id'] = $this->getParam('content_id');
		$data['content_type'] = $this->getParam('content_type');
		$data['asc_or_desc'] = 'DESC';
		$data['orderBy'] = 'time'; 
//		die_a($data);
        $this->viewParams['id'] = $this->getParam('id');
		$this->viewParams['form'] = new comment_Form_Comment();
		$sess = new Zend_Session_Namespace(CLU_NS);
		$actionUrl = "/" .$sess->viewLang . "/comment/ajax/new-comment";
        $this->viewParams['form']->cluBuild(array('action' => 'new', 
        						'action_url' => $actionUrl, 
        						'control' => 'ajax', 
        						'content_type' => $data['content_type'], /*blog, place or user*/
        						'region' => $this->widget['region'],						
                                /*'userPermissions' => $sess->userPermissions,*/ 
                                'language' => $sess->viewLang ));
		//$page = 1; 
		$sql = $this->m->search($data);
		$paginator = $this->generatePaginator($sql, 1, 15, 7, 'Jumping');
		
//		   $this->mService->updateDbAfterComments($nodeTypeInfo, $nodeId);
		   
		   
		$this->viewParams['paginator'] = $paginator;
		$this->viewParams['content_id'] = $this->getParam('content_id');
		$this->viewParams['content_poster_id'] = $this->getParam('content_poster_id');
		$this->viewParams['content_type'] = $this->getParam('content_type');
		$this->viewParams['region'] = $this->widget['region'];
	}
}
?>